/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GameHallServer;

import GameHallDBController.HallDeskDB;
import WebServiceDBController.GamingStateDB;
import WebServiceModel.GamingStateModel;
import java.util.ArrayList;

/**
 *
 * @author Peach
 */
public class GameHallServer {
    public void quitGame(int id, int room, int desk){
        HallDeskDB db=new HallDeskDB();
        db.QuitGame(id, room, desk);
        GamingStateModel model=new GamingStateModel();
        model.setDeskID(room+","+desk);
        GamingStateDB gaminDB= new GamingStateDB();
        gaminDB.ClearOption(model);
    }
    
    public void takeGame(int id, int room, int desk){
        HallDeskDB db=new HallDeskDB();
        db.PartakeGame(id, room, desk);
        if(db.getDeskInfo(room,desk).getPlayers()==2){
            GamingStateModel model=new GamingStateModel();
            model.setDeskID(room+","+desk);
            GamingStateDB gaminDB= new GamingStateDB();
            gaminDB.InsertOption(model);
        }
    }
    
    public ArrayList<Integer> getFreeDeskList(int room){
        HallDeskDB db=new HallDeskDB();
        return db.getFreeDeskList(room);
    }
    
    public void exchangeTurn(int room, int desk){
        HallDeskDB db=new HallDeskDB();
        db.RestartGameExchangeTurn(room, desk);
    }
}
